/**
 * 目标：搭建静态资源服务器
 * npm i koa-static
 */
const Koa = require('koa')
const app = new Koa()

const path = require('path')

/**
 * 引入koa-static
 */
const static = require('koa-static')
const staticPath = './static'
app.use(static(
  path.join(__dirname, staticPath)
))

/**
 * static会覆盖掉这个
 */
// app.use(async (ctx, next) => {
//   ctx.body = 'hello koa2'
//   await next()
// })

app.listen(3000, () => {
  console.log('服务器在127.0.0.1:3000运行中...')
})